#pragma once
#ifndef memory_h__
#define memory_h__

template <class T>
bool safeDelete(T *&pointer)
{
    if (pointer)
    {
        T *backup = pointer;
        pointer = nullptr;
        delete backup;
        return true;
    }
    return false;
}
template <class T>
bool safeDeleteSwap(const T *&pointer, T *newPointer)
{
    if (pointer)
    {
        const T *backup = pointer;
        pointer = newPointer;
        delete backup;
        return true;
    }
    else
    {
        pointer = newPointer;
    }
    return false;
}

#endif // memory_h__
